//
//  FoodMaterialData.m
//  ZCooking
//
//  Created by LL.F on 16/09/15
//  Copyright (c) __ORGANIZATIONNAME__. All rights reserved.
//

#import "FoodMaterialData.h"
#import "FoodMaterialSpices.h"
#import "FoodMaterial.h"

@implementation FoodMaterialData

+ (NSDictionary *)objectClassInArray{
    return @{@"spices" : [FoodMaterialSpices class], @"material" : [FoodMaterial class]};
}
- (void)setValue:(id)value forKey:(NSString *)key
{
    
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"spices"]) {
        NSMutableArray<FoodMaterialSpices *>  *secDataArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            FoodMaterialSpices *secData = [FoodMaterialSpices modelWithDic:dic];
            [secDataArray addObject:secData];
        }
        _spices = secDataArray;
    }
    if ([key isEqualToString:@"material"]) {
        NSMutableArray<FoodMaterial *>  *secDataArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            FoodMaterial *secData = [FoodMaterial modelWithDic:dic];
            [secDataArray addObject:secData];
        }
        _material = secDataArray;
    }
}
@end
